{% extends "base.html" %}
{% set active_page = "pool_stats" %}
{% set page_title = "Pool Stats - Block and Hashrate information" %}
{% block body %}
<script>
$(document).ready(function() {
  {# Initial graph generation #}
  generate_graph($('#chart'), {address: 'pool'});
});
</script>

<div class="row row-header">
  <div class="col-lg-12">
    <h2>{{ _("Pool Hashrate") }}
    <div class="btn btn-default btn-sm collapse-button" data-toggle="collapse" data-target="#chart" id="hashrate-collapse">{% if hide_hr %}[+]{% else %}[-]{% endif %}</div>
    </h2>
    <div class="col-lg-12" id="chart">
      <ul class="nav nav-tabs">
        <li class="tab hour"><a>{{ _("Hour") }}</a></li>
        <li class="tab day"><a>{{ _("Day") }}</a></li>
        <li class="tab month"><a>{{ _("Month") }}</a></li>
      </ul>
      <div style="height:400px;">
        <img src="{{ config['assets_address'] | safe }}/img/712.GIF" style="position:absolute;padding-top:150px;padding-left:400px;"><svg></svg>
      </div>
    </div>
  </div>
</div>

{% if server_status %}
<br />
<div class="row page-header">
  <h2><i class="fa fa-cog"></i> &nbsp; {{ _("Stratum Status") }}</h2>
  <div class="col-lg-12">
    <div class="bs-example table-responsive">
      <table class="table table-striped table-hover tablesorter" id="blockTable">
        <thead>
          <tr>
            <th>{{ _("Server") }}</th>
            <th>{{ _("Algo") }}</th>
            <th>{{ _("Chain") }}</th>
            <th>{{ _("Currently Mining") }}</th>
            <th>{{ _("Hashrate (last minute)") }}</th>
            <th>{{ _("Workers") }}</th>
            <th>{{ _("Miners") }}</th>
            <th>{{ _("Past 4d Profit:") }}</th>
          </tr>
        </thead>
        <tbody>
        {% for pp, data in server_status.iteritems() %}
        {% set pp = powerpools[pp] %}
        <tr>
          <th>
            <i class="fa fa-circle" style="color:{% if data['offline'] %}#B12627{% else %}#5BCE00{% endif %}"
                data-toggle="tooltip" data-placement="right"
                title="{% if data['offline'] %}Offline{% else %}Online{% endif %}"></i>&nbsp;{{ pp.stratum_address }} (diff {{pp.diff}})
          </th>
          <td>{{ pp.chain.algo.display }}</td>
          <td>{{ pp.chain.title }} ({{ pp.chain.type }})</td>
          <td>{{ data['currently_mining'] }}</td>
          <td>{{ data['hashrate'] | hashrate }}</td>
          <td>{{ "{:,}".format(data['workers']) }}</td>
          <td>{{ "{:,}".format(data['miners']) }}</td>
          <td>{{ data['profit_4d'] }} {{ _("BTC/MH") }}</td>
        </tr>
        {% endfor %}
        </tbody>
      </table>
    </div>
  </div>
</div>
{% endif %}

<br />
<div class="row row-header">

  <div class="col-sm-9">
    <h2>
      {{ _("Recently Mined Blocks") }}
    </h2>
  </div>
  <div class="col-sm-3 text-right " style="min-height: 67px;">
   <div class="checkbox" style="position:absolute;bottom:0;right:0;">
      <label>
        <input type="checkbox" id="hide-merged"
               name="hide-merged" checked
               data-toggle="collapse" data-target=".merged">
        {{ _("Hide merge mined currencies") }}
      </label>
    </div>
  </div>

  <ul class="nav nav-tabs algo-tabs">
    <li class="tab block-stats{% if block_stats_tab == 'all' %} active{% endif %}"
        data-algo="all">
      <a href="#">{{ _("All Algos") }}</a></li>
  {% for algo, currencies in network_data.iteritems() %}
    <li class="tab block-stats{% if block_stats_tab == algo %} active{% endif %}"
        data-algo="{{ algo }}"><a href="#">{{ algo }}</a></li>
  {% endfor %}
  </ul>

  <div class="col-sm-12 collapse {% if not hide_hr %}in{% endif %}" id="chart"
       style="border-top:1px solid #4e5d6c;">
    {% for algo, currencies in network_data.iteritems() %}
    <div class="row algo {{ algo }}">
      {% for currency, round_data in currencies.iteritems() if round_data['status'] != 'Idle'%}
        {% include "pool_stats_currency_info.html" %}
      {% endfor %}
      {% for currency, round_data in currencies.iteritems() if round_data['status'] == 'Idle'%}
        {% include "pool_stats_currency_info.html" %}
      {% endfor %}
    </div>
    {% endfor %}
  </div>

</div>
{% endblock %}
